import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

const User = resolve => require(['@/components/user/user.vue'], resolve)
const Message = resolve => require(['@/components/message/message.vue'], resolve)

const Data = resolve => require(['@/components/data/data.vue'], resolve)
const Project = resolve => require(['@/components/project/project.vue'], resolve)
const ProjectList = resolve => require(['@/components/project/project-list.vue'], resolve)
const AppStore = resolve => require(['@/components/appStore/appStore.vue'], resolve)
const Group = resolve => require(['@/components/group/group.vue'], resolve)
const GroupMembers = resolve => require(['@/components/group/group-list.vue'], resolve)
const Developer = resolve => require(['@/components/developer/developer.vue'], resolve)
const PrivateData = resolve => require(['@/components/data/private-data.vue'], resolve)
const PublicData = resolve => require(['@/components/data/public-data.vue'], resolve)
const GroupData = resolve => require(['@/components/data/group-data.vue'], resolve)
const DeptData = resolve => require(['@/components/data/dept-data.vue'], resolve)
const RegData = resolve => require(['@/components/data/reg-data.vue'], resolve)
const StarData = resolve => require(['@/components/data/star-data.vue'], resolve)
const Key = resolve => require(['@/components/developer/key.vue'], resolve)
const Resource = resolve => require(['@/components/source/source.vue'], resolve)
const ResourceReg = resolve => require(['@/components/resourceReg/resourceReg.vue'], resolve)
const ResourceRegList = resolve => require(['@/components/resourceReg/resourceReg-list.vue'], resolve)
const PublicImagery = resolve => require(['@/components/data/public-imagery.vue'], resolve)
const ResourceCenter = resolve => require(['@/components/resourceCenter/resource-center.vue'], resolve)
// const ResourcePop = resolve => require(['@/components/resourceCenter/pop.vue'], resolve)
// const ResourceDraw = resolve => require(['@/components/resourceCenter/draw.vue'], resolve)
// const ResourceBusiness = resolve => require(['@/components/resourceCenter/business.vue'], resolve)
// const ResourceHomework = resolve => require(['@/components/resourceCenter/homework.vue'], resolve)
// const ResourceMigration = resolve => require(['@/components/resourceCenter/migration.vue'], resolve)
// const ResourceOD = resolve => require(['@/components/resourceCenter/od.vue'], resolve)
// const ResourcePreApply = resolve => require(['@/components/resourceCenter/preapply.vue'], resolve)
// const ResourceApply = resolve => require(['@/components/resourceCenter/apply.vue'], resolve)
// const ResourceList = resolve => require(['@/components/resourceCenter/list.vue'], resolve)

const WorkOrder = resolve => require(['@/components/workOrder/workOrder.vue'], resolve)
const WorkOrderList = resolve => require(['@/components/workOrder/workOrderList.vue'], resolve)
const WorkOrderSubmit = resolve => require(['@/components/workOrder/workOrderSubmit.vue'], resolve)


var router = new Router({

  mode: process.env.NODE_ENV === 'development' ? 'hash' : ((window.history && window.history.pushState) ? 'history' : 'hash'),

  routes: [{
      path: '/data',
      redirect: '/data/private-data',
      name: 'Data',
      component: Data,
      children: [{
          path: 'private-data',
          component: PrivateData,
          name: 'PrivateData'
        },
        {
          path: 'private-data/:uid/:view',
          name: 'PrivateDataView',
          component: PrivateData
        },
        {
          path: 'public-data',
          name: 'PublicData',
          component: PublicData
        },
        {
          path: 'public-data/:uid/:view',
          name: 'PublicDataView',
          component: PublicData
        },
        {
          path: 'group-data',
          name: 'GroupData',
          component: GroupData
        },
        {
          path: 'group-data/:uid/:view',
          name: 'GroupDataView',
          component: GroupData
        },
        {
          path: 'dept-data',
          name: 'DeptData',
          component: DeptData
        },
        {
          path: 'dept-data/:uid/:view',
          name: 'DeptDataView',
          component: DeptData
        },
        {
          path: 'reg-data',
          name: 'RegData',
          component: RegData
        },
        {
          path: 'reg-data/:uid/:view',
          name: 'RegDataView',
          component: RegData
        },
        {
          path: 'bookmark/:bookmarkUid',
          component: StarData,
          name: 'StarData'
        },
        {
          path: 'bookmark/:bookmarkUid/:uid/:view',
          name: 'StarDataView',
          component: StarData
        },
        {
          path: 'public-imagery',
          component: PublicImagery,
          name: 'PublicImagery'
        },

      ]

    },
    {
      path: '/project',
      name: 'Project',
      component: Project,
      redirect: '/project/all',
      children: [{
          path: 'all',
          component: ProjectList,
          name: 'AllProjects'
        },
        {
          path: '/project/:type',
          component: ProjectList,
          name: 'AppProjects'
        }
      ]
    },
    {
      path: '/resourceReg',
      name: 'resourceReg',
      component: ResourceReg,
      redirect: '/resourceReg/public',
      children: [{
        path: '/resourceReg/:type',
        component: ResourceRegList,
        name: 'AllResourceRegs'
      }]
    },
    {
      path: '/workOrder',
      name: 'workOrder',
      component: WorkOrder,
      redirect: '/workOrder/list',
      children: [{
          path: '/workOrder/list',
          component: WorkOrderList,
          name: 'WorkOrderList'
        },
        {
          path: '/workOrder/submit',
          component: WorkOrderSubmit,
          name: 'WorkOrderSubmit'
        },
      ]
    },
    {
      path: '/appStore',
      name: 'AppStore',
      component: AppStore
    },
    {
      path: '/group',
      name: 'Group',
      component: Group,
      redirect: '/group/all',
      children: [{
          path: 'all',
          component: GroupMembers,
          name: 'AllMembers'
        },
        {
          path: '/group/:groupUid',
          component: GroupMembers,
          name: 'GroupMemebers'
        }
      ]
    },
    {
      path: '/develop',
      name: 'Developer',
      redirect: '/develop/key',
      component: Developer,
      children: [{
        path: 'key',
        name: 'key',
        component: Key
      }]
    },
    {
      path: '/resourceCenter',
      name: 'ResourceCenter',
      component: ResourceCenter,
    },
    {
      path: '/resource',
      name: 'Resource',
      component: Resource
    },
    {
      path: '/',
      //redirect: '/data'
      redirect: '/resourceCenter'
    },
    {
      path: '/message/:name',
      name: 'Message',
      component: Message
    },
    {
      path: '/user',
      redirect: '/user/profile'
    },
    {
      path: '/user/:name',
      name: 'User',
      component: User
    },
    {
      path: '*',
      redirect: '/'
    },
  ]
});

export default router;
